import {Component, EventEmitter, Input, Output} from '@angular/core';

@Component({
  selector: 'app-header',
  templateUrl: './header.component.html',
  styleUrl: './header.component.scss'
})
export class HeaderComponent {
  @Input()
  tabItems: string[] = [];
  activeIndex: number = 1;
  active:boolean[] = new Array(this.tabItems.length).fill(false);
  @Output()
  activeIndexChange = new EventEmitter<number>();
  constructor() {
    this.active[this.activeIndex] = true;
    setTimeout(()=>{
      this.tabClick(0)
    },100)
  }

  tabClick(index: number) {
    this.active[this.activeIndex] = false;
    this.activeIndex = index;
    this.active[this.activeIndex] = true;
    this.activeIndexChange.emit(this.activeIndex);
  }
}
